package com.qf.test;

import com.qf.pojo.User;
import javafx.animation.KeyValue;
import org.junit.Test;
import org.springframework.util.SerializationUtils;
import redis.clients.jedis.Jedis;


import java.io.Serializable;
import java.util.Date;

public class Demo2 {
    @Test
    public void TestSet() {
        Jedis jedis = new Jedis("192.168.200.129", 6379);

        User user = new User(1,"张三",new Date());

        byte[] key = SerializationUtils.serialize("user");
        byte[] value = SerializationUtils.serialize(user);

        jedis.set(key, value);

        jedis.close();
    }


    @Test
    public void TestGet() {
        Jedis jedis = new Jedis("192.168.200.129", 6379);

        byte[] key = SerializationUtils.serialize("user");


        byte[] value = jedis.get(key);

        User user = (User)SerializationUtils.deserialize(value);

        System.out.println("======="+user);

        jedis.close();


    }
}
